<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<br/>

<form:form action="performance.pt" method="POST">
	<input type="hidden" name="action_value" id="idActionValue" value="" />
	
	<form:errors path="*" cssClass="error-message"/>
	
	<table class="input-table">
		<tbody>
			<tr>
				<td>Report Type</td>
				<td>
					<form:select path="reportType" onchange="doSubmit('action_report_type_select')" cssClass="element-select">
						<form:option value="" label=""/>
						<form:options items="${reportTypes}"/>
					</form:select>
				</td>
				<td>Course</td>
				<td>
					<form:select path="course" onchange="doSubmit('action_course_select')" cssClass="element-select">
						<form:option value="" label=""/>
						<form:options items="${courses}" itemValue="idAsString" itemLabel="name"/>
					</form:select>
				</td>
				<td>Semester</td>
				<td>
					<form:select path="subCourse" onchange="doSubmit('action_semester_select')" cssClass="element-select">
						<form:option value="" label=""/>
						<form:options items="${semesters}" itemValue="idAsString" itemLabel="name"/>
					</form:select>
				</td>
				<td></td>
			</tr>
			
			<tr>
				<c:if test="${command.reportType eq 'STUDENT_EXAMS'}">
				<td>Student</td>
				<td>
					<form:select path="student" cssClass="element-select">
						<form:option value="" label=""/>
						<form:options items="${students}"  itemValue="idAsString" itemLabel="name"/>
					</form:select>
				</td>
				</c:if>
				
				<c:if test="${command.reportType eq 'STUDENT_EXAMS' || command.reportType eq 'STUDENTS_EXAM'}">
				<td>Subject</td>
				<td>
					<form:select path="subject" cssClass="element-select">
						<form:option value="" label=""/>
						<form:options items="${subjects}"  itemValue="idAsString" itemLabel="name"/>
					</form:select>
				</td>
				
				<td>Exam Type</td>
				<td>
					<form:select path="examType" cssClass="element-select">
						<form:option value="" label=""/>
						<form:options items="${examTypes}"/>
					</form:select>
				</td>
					
				</tr>
				</c:if>
			</tr>	
			
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td><input type="button" value="Show" name="action_btn_show" onclick="doSubmit('action_show')"/></td>
			</tr>
		</tbody>
	</table>
	
	
	<c:if test="${command.reportType eq 'STUDENT_EXAMS'}">
	<table border=1 wisth="100%">
			<tbody>
			<c:set var="result1" value="${results['RESULT1']}"/>
			<tr>
				<th width="30%">Exams</th>
				<c:forEach items="${result1}" var="result">
				<td><c:out value="${result.exam.name}"/></td>
				</c:forEach>
			</tr>	
			<tr>
				<th width="30%">Marks</th>
				<c:forEach items="${result1}" var="result">
				<td><c:out value="${result.obtainedMark}"/>/<c:out value="${result.exam.totalMark}"/></td>
				</c:forEach>
			</tr>				
			
		</tbody>
	</table>
	</c:if>
	
	
	<c:if test="${command.reportType eq 'STUDENTS_EXAM'}">
	<table border=1 >
			<tbody>
			<c:set var="headers" value="${results['ROW_0']}"/>
			<tr>
				<th>&nbsp;</th>
				<c:forEach items="${headers}" var="header">
				<td><c:out value="${header}"/></td>
				</c:forEach>
			</tr>
			
			
			
		</tbody>
	</table>
	</c:if>

</form:form>